﻿using System;
using System.Reactive.Disposables;
using System.Reactive.Subjects;
using System.Reactive.Linq;
using System.Threading;
using System.Windows.Forms;

namespace Demo
{
	public partial class TestingForm : Form
	{
		private MyObservableClass x;

		public TestingForm()
		{
			InitializeComponent();

			//hot and cold streams


			var repeat = Observable.Repeat(1);
			var interval = Observable.Interval(new TimeSpan(0, 0, 0, 30));  //days, minutes, hours, seconds
			var range = Observable.Range(1, 100);

			var generated = Observable.Generate(
				5,				//initial state
				i => i < 15,    //condition
				i => i + 3,     //iteration
				i => i.ToString());  //result selector


			var rnd = new Random();
			var lastPrice = 100.0;
			var stockTicks = Observable.Interval(TimeSpan.FromMilliseconds(250))
				.Select(i =>
				{
					var variation =
						rnd.NextDouble() - 0.5;
					lastPrice += variation;
					return lastPrice;
				});
		}


	}

}